//用于封装公共方法
var commomFun={
		/*舱位类型字母转换为名称字符串*/
		cabinStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "F": return "头等舱";
				case "C": return "商务舱";
				case "Y": return "经济舱";
				default: return n;
			}
		},
		/*货币类型*/
		currencyMStr: function(n){
			if(n==null || n==undefined||n=="") return "";
			switch(n.toString()){
				case "CNY": return "人民币";
				case "MYR": return "马币";
				default: return n;
			}
		},
		/*舱位类型汉字转换为字母*/
		cabinStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "头等舱": return "F";
				case "商务舱": return "C";
				case "经济舱": return "Y";
				default: return "未知"
			}
		},
		/*方案类型字母转换为名称字符串*/
		typeStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "QW": return "切位";
				case "SK": return "散客";
				default: return "未知"
			}
		},
		/*销售类型类型数字转换为名称字符串*/
		orderSaleStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "硬切";
				case "2": return "软切";
				case "3": return "散客";
				default: return "未知"
			}
		},
		/*运价方案状态字母转换为名称字符串*/
		priceStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "VA": return "已有效";
				case "IV": return "已失效";
				default: return "未知"
			}
		},
		/*订单状态字母转换为名称字符串*/
		orderStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){		
				case "6": return "待确认";			
				case "0": return "待生效";
				case "1": return "待支付";
				case "2": return "待出票";
				case "3": return "已出票";
				case "4": return "已取消";
				case "5": return "已支付";
				default: return "未知"
			}
		},
		/*订单状态转换为数字*/
		orderStatusNum: function(n){
			if(n==null||n==undefined||n=="undefined") return "";
			switch(n.toString()){		
				case "待确认": return "6";			
				case "待生效": return "0";
				case "待支付": return "1";
				case "待出票": return "2";
				case "已出票": return "3";
				case "已取消": return "4";
				case "已支付": return "5";
				default: return "未知"
			}
		},
		/*性别数字转换为名称字符串*/
		genderStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "男";
				case "2": return "女";
				default: return ""
			}
		},
		/*旅客类型数字转换为名称字符串*/
		typeNumStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "成人";
				case "2": return "儿童";
				case "3": return "婴儿";
				default: return "未知"
			}
		},
		//封装函数  实现若值为null或undefined 转化为空
		toEmptyString: function(string){			
			if(string == null ||string == "undefined"|| string == undefined||string == "NaN"){
				return "";
			}else{
				return string
			};
		},
		//
		toLine: function(string){			
			if(string == null ||string == "undefined"|| string == undefined||string == "NaN"){
				return "-";
			}else{
				return string
			}
		},
		//封装函数  实现若值为null或undefined 转化为未知
		toUnknownString: function(string){
			if(string == null || string == undefined ||string==""){
				return "未知";
			}else{
				return string
			};
		},
		//酒店信息
		hotelDetail: function(string){
			if(string == null || string == undefined ||string==""){
				return "无";
			}else{
				return string
			};
		},
		//证件类别数字转换为名称字符串
		certificateTypeStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "身份证";
				case "2": return "护照";
				default: return ""
			}
		},

		//合同状态数字转换为名称字符串
		documentTypeStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "待审核";
				case "2": return "合同签署";
				case "3": return "合同退回";
				case "4": return "押金已支付";
				case "5": return "合同中止";
				case "6": return "合同取消";
				case "7": return "合同完成";
				default: return "未知"
			}
		},
		//订单状态数字转换为名称字符串
		orderTypeStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "待生效";			
				case "1": return "待支付";
				case "5": return "已支付";
				case "6": return "待确认";
				case "2": return "待出票";
				case "3": return "已出票";
				case "4": return "已取消";
				default: return "未知"
			}
		},

		//运价类型字母转换为名称字符串
		owRtCdeStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "OW": return "单程";
				case "RT": return "往返";
				case "CT": return "环程";
				case "OJ": return "缺口程";
				default: return "未知"
			}
		},
		//星期的转换
		numToWeekStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "星期一";
				case "2": return "星期二";
				case "3": return "星期三";
				case "4": return "星期四";
				case "5": return "星期五";
				case "6": return "星期六";
				case "7": return "星期日";
				default: return "未知"
			}
		},
		//间隔周数的转换
		WeekStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "同周";
				case "1": return "下一周";
				case "2": return "下二周";
				case "3": return "下三周";
				case "4": return "下四周";
				case "5": return "下五周";
				case "6": return "下六周";
				case "7": return "下七周";
				default: return "未知"
			}
		},
		//币种字母转换为名称字符串
		currencyStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "CNY": return "人民币";
				default: return "未知"
			}
		},
		//用户状态转换为名称字符串
		userStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "正常";
				case "1": return "失效";
				default: return "未知"
			}
		},
		//资源类型转换为名称字符串
		resourceStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "菜单";
				case "1": return "按钮";
				default: return "未知"
			}
		},
		//角色转换为名称字符串
		roleStatusStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "101": return "超级管理员";
				case "102": return "航空事业部";
				case "103": return "计调部";
				case "104": return "市场部";
				case "105": return "销售部";
				default: return "未知"
			}
		},
		//角色汉子转换为数字
		roleStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "超级管理员": return "101";
				case "航空事业部": return "102";
				case "计调部": return "103";
				case "市场部": return "104";
				case "销售部": return "105";
				default: return "未知"
			}
		},
		//将航班状态转化为汉字
		flightStatusToStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "O": return "执行中";
				case "U": return "未开始";
				case "D": return "已完成";
				case "C": return "已取消";
				default: return "未知"
			}
		},
		//将汉字转化为航班状态
		strToFlightStatus: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "执行中": return "O";
				case "未开始": return "U";
				case "已完成": return "D";
				case "已取消": return "C";
				default: return "未知"
			}
		},
		//将增班减班字符转化为汉字
		amTo: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "A": return "增班";
				case "M": return "减班";				
				default: return "未知"
			}
		},
		//将行程字符转化为汉字
		gradesTypeToStr: function(n){
			if(n==null || n==undefined || n=="undefined") return "";
			switch(n.toString()){
				case "1": return "去程";
				case "2": return "回程";	
				case "3": return "往返";	
				default: return "未知"
			}
		},
		//追位行程类型
		seatAddRoundType: function(n){
			if(n==null || n==undefined || n=="undefined") return "";
			switch(n.toString()){
				case "1": return "去程";
				case "2": return "回程";	
				case "0": return "往返";	
				default: return "未知"
			}
		},
		roundTypeStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "";
				case "1": return "去程";	
				case "2": return "回程";	
				default: return "未知"
			}
		},
		//将附加项订单状态字符转化为汉字
		otherOrderTypeToStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "0": return "已取消";
				case "1": return "待支付";	
				case "2": return "已支付";	
				case "3": return "已审核";
				case "4": return "不通过";	
				case "5": return "待审核";	
				default: return "未知"
			}
		},
		//将散客状态字符转化为汉字
		skTypeToStr: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "CPSK": return "产品散客";
				case "ZYSK": return "自由散客";	
				case "NOSK": return "不支持散客";					
				default: return "未知"
			}
		},
		//修改旅客信息
		changePassengerMessStstus: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "1": return "待审核";
				case "2": return "审核不通过";	
				case "3": return "待支付";	
				case "4": return "已支付";	
				case "5": return "已取消";	
				default: return "未知"
			}
		},
		//退款路径
		refundChannel: function(n){
			if(n==null || n==undefined) return "";
			switch(n.toString()){
				case "order": return "订单抵充";
				case "account": return "退回账户";					
				default: return "未知"
			}
		}


}
//输入校验
var inputCheckoutFun = {
		//为空
		Empty:function(input,name,msg){
			var name = name||"输入项";
			var msg = msg||"不能为空!";
			if(input==""||input==null){
				layer.msg(name+msg,{icon:2});
				throw name+msg;
			}
		},
		//价格校验
		price:{
			//不能为空不能为负，最多保留2位小数
			normal:function(input,name,msg){
				var reg = /^\d+(\.\d{0,2})?$/;
				var name = name||"输入项";
				var defaults = "不能为空!";
				var msg = msg||"格式有误!";
				if(input==""){
					layer.msg(name+defaults,{icon:2});
					throw name+defaults;
				}else if(!reg.test(input)){
					layer.msg(name+msg,{icon:2});
					throw name+msg;
				}
			},
			//价格可以为空
			allowEmpty:function(input,name,msg){
				var reg = /^\d+(\.\d{0,2})?$/;
				var name = name||"价格";
				var msg = msg||"格式有误!";
				if((!reg.test(input))&&(input!="")){
					layer.msg(name+msg,{icon:2});
					throw name+msg;
				}
			}
		},
		//座位数校验
		seatCount:{
			//座位数不可以为空不可以为负，整数	
			normal:function(input,name,msg){				
				var reg = /^\+?[0-9][0-9]*$/;
				var name = name||"座位数";
				var defaults = "不能为空!";
				var msg = msg||"格式有误!";
				if(input==""){
					layer.msg(name+defaults,{icon:2});
					throw name+defaults;
				}else if(!reg.test(input)){
					layer.msg(name+msg,{icon:2});					
					throw name+msg;
				}
			},
			//座位数可以为空
			allowEmpty:function(input,name,msg){
				var reg = /^\+?[0-9][0-9]*$/;
				var name = name||"座位数";
				var msg = msg||"格式有误!";
				if((!reg.test(input))&&(input!="")){
					layer.msg(name+msg,{icon:2});
					throw name+msg;
				}
			}
		},
		//出票率，票损率
		rate:{
			//率不可以为空，最多保留2位小数
			normal:function(input,name,msg){
				var reg = /^\d+(\.\d{0,2})?$/;
				var name = name||"百分比";
				var defaults = "不能为空!";
				var msg = msg||"格式有误!";
				if(input==""){
					layer.msg(name+defaults,{icon:2});
					throw name+defaults;
				}else if(input>100){
					layer.msg(name+"不能大于100!",{icon:2});
					throw name+"不能大于100!";
				}else if(!reg.test(input)){
					layer.msg(name+msg,{icon:2});
					throw name+msg;
				}
			},
			//率可以为空
			allowEmpty:function(input,name,msg){
				var reg = /^\d+(\.\d{0,2})?$/;
				var msg = msg||"格式有误!";
				var name = name||"百分比";
				if((!reg.test(input))&&(input!="")){
					layer.msg(name+msg,{icon:2});
					throw name+msg;
				}
			}
		}
		
}

//____________________________________________去程机场三字码联想_________________________________	   
		    $(".queryDepThreeWord").keyup(function(){
		    	if($(this).val()!==""){
		    		getDepCnNm()
		    	}else{
		    		$(".hiddeDepInput").text("")
		    		$(".threeWordBox").remove();
		    	}	    	
			})
			$(".derJc").delegate(".CnNm","click",function(){
				$(".queryDep").val($(this).text())
				$(".hiddeDepInput").text($(this).find("i").text())
				$(".threeWordBox").remove();
			})	
			$(".derJc").delegate(".threeWordBox","mouseleave",function(){				
				$(".threeWordBox").remove();
			})	
			function getDepCnNm(){
				var threeWord = $(".queryDepThreeWord").val();	
				$(".threeWordBox").remove();
				$.ajax({
					type:"get",
					url:"../Airapt/query?airapt="+threeWord+"&temp="+Math.random(),
					dataType:"json",
					success:function(data){	
						var str1="";
						str1+="<i class='threeWordBox'></i>";
						$(".derJc").append(str1)
						var str2="";						
						for(var i=0;i<data.data.length;i++){
							str2+="<p class='CnNm' style='cursor:pointer;overflow:hidden;width:100%;height:20px;line-height:20px;padding-left:5px;'>"+data.data[i].airportCnNm+"<i>"+data.data[i].airportCode+"</i></p>"
						}
						$(".threeWordBox").append(str2);
						
					}
				})
			}
//____________________________________________回程机场三字码联想_________________________________				
			$(".queryArrThreeWord").keyup(function(){
				if($(this).val()!==""){
		    		getArrCnNm()
		    	}else{
		    		$(".hiddeArrInput").text("")
		    		$(".threeWordBox").remove();
		    	}	
			})
			$(".arrJc").delegate(".CnNm","click",function(){
				$(".queryArr").val($(this).text())
				$(".hiddeArrInput").text($(this).find("i").text())
				$(".threeWordBox").remove();
			})	
			$(".arrJc").delegate(".threeWordBox","mouseleave",function(){				
				$(".threeWordBox").remove();
			})	
			function getArrCnNm(){
				var threeWord = $(".queryArrThreeWord").val();	
				$(".threeWordBox").remove();
				$.ajax({
					type:"get",
					url:"../Airapt/query?airapt="+threeWord+"&temp="+Math.random(),
					dataType:"json",
					success:function(data){	
						var str1="";
						str1+="<i class='threeWordBox'></i>";
						$(".arrJc").append(str1)
						var str2="";						
						for(var i=0;i<data.data.length;i++){
							str2+="<p class='CnNm' style='cursor:pointer;overflow:hidden;width:100%;height:20px;line-height:20px;padding-left:5px;'>"+data.data[i].airportCnNm+"<i>"+data.data[i].airportCode+"</i></p>"
						}
						$(".threeWordBox").append(str2);
						
					}
				})
			}
			   
	   
	  
//____________________________________________页面传参_________________________________
	   function getHref(){
		    var s=decodeURI(window.location.search.substr(1));
		    var arr1= s.split("&");
		    var obj={};
		    $(arr1).each(function(i){
		        var arr=this.split("=");
		        obj[arr[0]]=arr[1];
		    })
		    return obj;
		}
		
		
//____________________________________________全选操作_________________________________		
		$(".checkAll").click(function(){
			if(this.checked){
				$(".check").prop('checked','checked')				
			}else{
				$(".check").prop('checked',false)		
			}
		})
		

//____________________________________________关闭弹出层（主要用于取消按钮上的点击事件）_________________________________	
		function closeWin(){
			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			parent.layer.close(index);
		}
//_____________________________________________________________________________去重函数
		function unique2(array){ 
			var n = {}, r = [], len = array.length, val, type; 
			for (var i = 0; i < array.length; i++) { 
			val = array[i]; 
			type = typeof val; 
			if (!n[val]) { 
			n[val] = [type]; 
			r.push(val); 
			} else if (n[val].indexOf(type) < 0) { 
			n[val].push(type); 
			r.push(val); 
			} 
			} 
			return r; 
		}

//——————————————————————————————————————————————————————————————————————————————获取时间间隔
		function getDaysInterval(a,b){
			var starttime = a.replace(new RegExp("-","gm"),"/");
			var endtime = b.replace(new RegExp("-","gm"),"/");
			var daysInterval = (new Date(endtime).getTime()-new Date(starttime).getTime())/1000/60/60/24
			return daysInterval;
		}
//——————————————————————————————————————————————————————————————————————————————将日期转化为星期
		function dateToWeek(date){
			var dayofweek = new Date(date).getDay();
			if(dayofweek=="0"){
				return "星期日";
			}
			if(dayofweek=="1"){
				return "星期一";
			}
			if(dayofweek=="2"){
				return "星期二";
			}
			if(dayofweek=="3"){
				return "星期三";
			}
			if(dayofweek=="4"){
				return "星期四";
			}
			if(dayofweek=="5"){
				return "星期五";
			}
			if(dayofweek=="6"){
				return "星期六";
			}		
		}
//
//___________________________________________加0函数__________________________
			function addZero(x){
				if(x>9){
					return x;
				}else{
					return "0"+x;
				}
			}		
		
		
		
